package com.wanmait.recruitment.controller;

import com.wanmait.recruitment.pojo.Money;
import com.wanmait.recruitment.service.MoneyService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("manage/money")
public class MoneyListController {
    @Resource
    private MoneyService moneyService;
    @RequestMapping("list")
    public void list(Model model){
        List<Money> monies = moneyService.findAll();
        model.addAttribute("monies",monies);
    }
    @RequestMapping("del")
    @ResponseBody
    public void del(String id){
        moneyService.delete(Integer.parseInt(id));
    }
    @RequestMapping("update")
    @ResponseBody
    public void update(Money money){
        moneyService.update(money);
    }
    @RequestMapping("insert")
    @ResponseBody
    public void insert(Money money){
        money.setEnable(true);
        moneyService.insert(money);
    }
}
